package com.zxj.transfer.orm.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

@Mapper
public interface UserAccountMapper {

    @Update("UPDATE user_account SET us_account = us_account - #{usAccount} WHERE (user_id = #{userId})")
    int subtractUsAccount(@Param("userId") Integer userId, @Param("usAccount") BigDecimal usAccount);

    @Update("UPDATE user_account SET us_account = us_account + #{usAccount} WHERE (user_id = #{userId})")
    int addUsAccount(@Param("userId") Integer userId, @Param("usAccount") BigDecimal usAccount);

    @Update("UPDATE user_account SET rmb_account = rmb_account - #{rmbAccount} WHERE (user_id = #{userId})")
    int subtractRmbAccount(@Param("userId") Integer userId, @Param("rmbAccount") BigDecimal rmbAccount);

    @Update("UPDATE user_account SET rmb_account = rmb_account + #{rmbAccount} WHERE (user_id = #{userId})")
    int addRmbAccount(@Param("userId") Integer userId, @Param("rmbAccount") BigDecimal rmbAccount);
}